import requests from "./request.js";
import mockRequests from "./mockRequest.js";

// 三级联动接口 get 无参
export const reqCategoryList = () => requests.get('/product/getBaseCategoryList');

// 获取banner (home首页轮播图接口)
export const reqGetBannerList = () => mockRequests.get('/banner');

// 获取floor数据
export const reqFloorlist = () => mockRequests.get('/floor');

// 获取搜索模块数据 post
/** 
{
 "category3Id": "61",
 "categoryName": "手机",
 "keyword": "小米",
 "order": "1:desc",
 "pageNo": 1,
 "pageSize": 10,
 "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
 "trademark": "4:小米"
}
*/
export const reqGetSearchInfo = (params) => requests({
    url: '/list',
    method: 'post',
    data: params
})

// 获取商品详情 get
export const reqGoodsInfo = (skuId) => requests.get(`/item/${skuId}`)

// 加入购物车或修改购物车商品 post /api/cart/addToCart/{ skuId }/{ skuNum }
// 这个请求只需要给服务器发数据，不需要返回什么东西
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests.post(`/cart/addToCart/${skuId}/${skuNum}`)

// 获取购物车列表 get /api/cart/cartList
export const reqShopCart = () => requests.get('/cart/cartList')

// 删除购物车商品 delete /api/cart/deleteCart/{skuId}
export const reqDeleteCart = (skuId) => requests.delete(`/cart/deleteCart/${skuId}`)

// 切换商品选中状态 /api/cart/checkCart/{skuId}/{isChecked} get
export const reqChangeChecked = (skuId, isChecked) => requests.get(`/cart/checkCart/${skuId}/${isChecked}`)

// 获取验证码
export const reqGetCode = (phone) => requests.get(`/user/passport/sendCode/${phone}`)

// 用户注册 /api/user/passport/register post
export const reqUserRegister = (data) => requests.post('/user/passport/register', data)

// 用户登录 /api/user/passport/login post
export const reqUserLogin = (data) => requests.post('/user/passport/login', data)

// 获取用户信息 /api/user/passport/auth/getUserInfo get
export const reqUserInfo = () => requests.get('/user/passport/auth/getUserInfo')

// 退出登录 /api/user/passport/logout get
export const reqLogout = () => requests.get('/user/passport/logout')

// 获取用户地址信息  /api/user/userAddress/auth/findUserAddressList get
export const reqAddressList = () => requests.get('/user/userAddress/auth/findUserAddressList')

// 获取订单交易页信息  /api/order/auth/trade get
export const reqTradeInfo = () => requests.get('/order/auth/trade')

// 提交订单 /api/order/auth/submitOrder?tradeNo={tradeNo} post
export const reqSubmitOrder = (tradeNo, date) => requests.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, date)

// 获取订单支付信息 /api/payment/weixin/createNative/{orderId} get
export const reqGetPay = (orderId) => requests.get(`/payment/weixin/createNative/${orderId}`)

// 获取支付订单状态 /api/payment/weixin/queryPayStatus/{orderId} get
export const reqPayStatus = (orderId) => requests.get(`/payment/weixin/queryPayStatus/${orderId}`)

// 获取我的订单 /api/order/auth/{page}/{limit} get
export const reqMyOrder = (page, limit) => requests.get(`/order/auth/${page}/${limit}`)
